#include<stdio.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
 char ch;
 FILE *fp;
 long count=0;
 char s[21];
 
 if(argc !=2)
 {
  printf("文件名是：%s\n",argv[0]);
  exit(EXIT_FAILURE);
 }
 if ((fp=fopen(argv[1],"r+"))==NULL)
 {
  fprintf(stderr,"不能打开文件\"%s\"\n",argv[1]);
  exit(EXIT_FAILURE);
 }
while(fscanf(fp,"%s",s)!=EOF)
        count++;
 
 fclose(fp);
 printf("File %s has %ld characters\n",argv[1],count);
 return 0;
}

 


